package com.example.cuibo.myapplicationhttp;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

/**
 * Created by cuibo on 2017/11/22.
 */

public class StreamTools {

    // 把一个inpustream 转成string
    public static String redStream(InputStream stream) throws Exception{
        // 内存输出流
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int len = -1;
        byte[] buffer = new byte[1024];
        while ((len=stream.read(buffer))!=-1){
            baos.write(buffer,0,len);
        }
        stream.close();
        String conten = new String(baos.toByteArray());
        return conten;
    };
}
